<template>
	<view>
        <u-popup :show="show" mode="bottom"  @close="closeShow" :round="10">
			<div>
				<div class="popup-con">
					<div class="popup-block-pay">
						<div class="price-sub-title">需支付金额</div>
						<div class="price-big-title">{{info.orderAmount}}</div>
					</div>
					<div class="popup-label">
						<div>请按以下信息进行银行转帐</div>
						<u-button class="custom-style" text="复制" size="mini" plain type="primary" :custom-style="{width:'60px'}" shape="circle" @click="copy"></u-button>
					</div>
					<u-cell-group>
						<u-cell title="公司名称" :value="info.storeName"></u-cell>
						<u-cell title="开户行" :value="info.bankName"></u-cell>
						<u-cell title="开户行帐号" :value="info.bankNumber"></u-cell>
					</u-cell-group>
					<div class="popup-label" style="margin-top:10px">
						<div>请按以下信息进行银行转帐</div>
					</div>
					<div>
						<u-upload
								:fileList="fileList1"
								@afterRead="afterRead"
								@delete="deletePic"
								name="1"
								:maxCount="1"
								:previewFullImage="true"
							></u-upload>
					</div>
				</div>
				
				<div class="u-flex popup-bottom" style="z-index: 5;">
					<u-button text="取消"  shape="circle" @click="closeShow"></u-button>
					<u-button text="确认"  shape="circle" type="warning" @click="saveForm" :loading="btnLoading"></u-button>
				</div>
				
			</div>
            
        </u-popup>
	</view>
</template>
<script>

import{imgCheck} from '@/plugins/upload/upload.js'
import {editOrder,waitPayData} from '@/config/api.js'
import store from '@/store';

const defaultForm={
	     orderId:'',
		 remark:'',
		 cancelReason:'',
    };
export default {
    name: 'payOrder',
    computed: {
    	
		
    },
	data() {
		return {
           show:false,
		   fileList1: [],
		   btnLoading:false,
		   orderId:'',
		   info:{}
		}
	},
    watch:{

    },
	created() {
	  
	
	},
	methods: {
		getInfo(){
			waitPayData({orderId:this.orderId}).then((res)=>{
				this.info = res
			})
		},
		// 复制
		copy() {
			uni.setClipboardData({
				data: this.info.storeName + '/' + this.info.bankName +'/'+this.info.bankNumber,
				success: () => {
					uni.showToast({
						icon: 'none',
						title: '复制成功'
					});
				}
			});
		},
	
		// 删除图片
		deletePic(event) {
			this.fileList1.splice(0, 1)
		},
		 // 新增图片
		 afterRead(event) {
			uni.showLoading({
				title: '上传中',
			});
			imgCheck(event.file.url).then((res)=>{
				console.log(res)
				this.fileList1 = [];
				if(res != ''){
					this.fileList1.push({url:res})
				}
				uni.hideLoading()
			}).catch(()=>{
				uni.hideLoading()
			})
		},
		init(item){
			this.show = true;
			this.orderId = item.orderId;
			this.fileList1 = []
			this.getInfo()
		},
		
       saveForm(){
		   if(this.fileList1.length == 0){
			   uni.showToast({
			     title: '请上传付款凭证',
			     icon: 'none'
			   });
			   return false
		   }
		   let data = {};
		   data.orderId = this.orderId;
		   data.offlinePayCertificate = this.fileList1[0]['url'];
		   data.operationType = 'buyerPay'
		   this.btnLoading = true;
		   editOrder(data).then(()=>{
			   this.btnLoading = false;
			   this.closeShow();
			   uni.showToast({
			     title: '付款凭证上传完成！供应商会按照约定的时间为您安排发货！',
			     icon: 'none',
			     duration: 3000,
			   });
			   this.$emit('refresh')
		   }).catch(()=>{
			   this.btnLoading = false;
		   })
	   },
	   closeShow(){
		   this.show = false
	   }
        
		
		
        
       
        
        
        
        
      
        
	}
};
</script>

<style lang="scss" scoped>
@import '@/style/common.scss';
.popupTitle{
	font-size:$b-font;
	font-weight: bold;
	text-align: center;
	line-height: 50px;
}
   .popup-con{
    	padding:0 16px 16px 16px;
    	.popup-block-pay{
    		text-align: center;
    		padding:20px;
    		.price-sub-title{
    			font-size:$s-font;
    			color:$g-font-color;
    			line-height: 30px;
    		}
    		.price-big-title{
    			font-size: 22px;
    			color:$theme-color;
    			font-weight:bold;
    			margin-top:10px;
    		}
    	}
    	.popup-label{
    		line-height: 40px;
    		font-size:$m-font;
    		color:$g-font-color;
    		@include flexbox(space-between,center)
    	}
    	.img-div{
    		width:210px;
    		height:210px;
    		border:1px solid $border-color;
    		margin:0 auto;
    		background: #f4f5f7;
    	}
        .send-list{
    		padding-top:$marginSpace;
    		.send-item{
    			border-radius: 8px;
    			padding:12px;
    			box-shadow: 0 0 5px rgba(0,0,0,0.1);
    			margin-bottom:$marginSpace;
    			.send-top{
    				@include flexbox(flex-start,flex-start);
    				font-size:$m-font;
    				.name{
    					padding-right:12px;
    					flex:1
    				}
    				.num{
    					font-weight: bold;
    					color:$theme-color
    				}
    			}
    			.send-middle{
    				font-size:$s-font;
    				color:$g-font-color;
    				line-height: 18px;
    				margin-top:5px;
    			}
    			.send-bottom{
    				text-align: right;
    				font-size:$s-font;
    				margin-top:16px
    			}
    		}
    	}
    	.category-list{
    		padding:36rpx 0;
    		.list-item{
    			@include flexbox(flex-start,flex-start);
    			margin-bottom:20rpx;
    			.item-title{
    				width: 126rpx;
    				height: 52rpx;
    				background: rgba(255,255,255,0.39);
    				border: 1px solid #B8B8B8;
    				border-radius: 9rpx;
    				font-size:$m-font;
    				text-align: center;
    				line-height: 52rpx;
    			}
    			.item-list{
    				padding-left:30rpx;
    				width:calc(100% - 126rpx);
    				overflow: hidden;
    				.item-ename{
    					font-size:$s-font;
    					color: #929292;
    					line-height: 52rpx;
    					width: 170rpx;
    					@include textoverflow(1);
    					float:left;
    				}
    			}
    		}
    	}
    	.goodsSn-list{
    		border: 1px solid #DEDEDE;
    		padding:0 10px;
    		font-size:$s-font;
    		margin-top:15px;
    		padding-bottom:10px;
    		.list-cell{
    			border-bottom:1px solid #DEDEDE;
    			@include flexbox(space-between,center);
    			line-height: 60rpx;
    			height:60rpx;
    		}
    		.list-cell:first-child{
    			
    		}
    	}
    	.audio-text{
    		font-size: 34rpx;
    		line-height: 48rpx;
    		color: #414141;
    		text-align: center;
    		padding-top:100rpx;
    	}
    	.audio-dh{
    		@include flexbox(space-between,center);
    	}
    
    }
    .popup-bottom{
    	background: #fff;
    	margin-top:10px;
    	padding:16px;
    }
    .popup-bottom-fixed{
    	position: fixed;
    	width:100%;
    	padding:16px;
    	box-sizing: border-box;
    	bottom:0
    }
    
    

</style>
